# coding:utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header

mail_host = "smtp.126.com"  # 设置服务器
mail_user = "a529548204@126.com"  # 用户名
mail_pass = "kkookko1515"  # 口令


def send(mail_host, mail_user, mail_pass):
    # 第三方 SMTP 服务

    # msg = MIMEText(mail_body, 'html', 'utf-8')
    msg = MIMEText('请查看附件内容！', 'plain', 'utf-8')
    msg['Subject'] = Header("自动化测试报告", 'utf-8')

    # 报错原因是因为“发件人和收件人参数没有进行定义
    msg['from'] = 'a529548204@126.com'
    msg['to'] = '529548204@qq.com'

    smtp = smtplib.SMTP()
    smtp.connect(mail_host, 25)
    smtp.login(mail_user, mail_pass)
    smtp.sendmail(from_addr=mail_user, to_addrs='529548204@qq.com', msg=msg.as_string())
    smtp.quit()


if __name__ == '__main__':
    send()
